# -*- coding: utf-8 -*- 
# @project : 《Atcoder》
# @Author : created by bensonrachel on 2021/9/23
# @File : 10.A - Frog 1.py

def frog_1():
    dp = [0]*(n+1)
    dp[1] = 0
    dp[2] = abs(a[2]-a[1])
    for i in range(3,n+1):
        dp[i] = min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]))
    return dp[n]

"""
青蛙跳台阶，一维单循环线性dp，记录跳到每一个位置的最小的total_cost。每次能跳一格或者两格。
"""
if __name__ == '__main__':
    n = int(input())
    a = [int(i) for i in input().split()]
    a = [0] + a
    ans = frog_1()
    print(ans)